﻿using System;

class ExtractBitValue

        // Write an expression that extracts from a given integer i the value of a given bit number b. Example: i=5; b=2 - value=1.

{
    static void Main()
    {
        Console.Write("Enter a number: ");
        int i = int.Parse(Console.ReadLine());
        Console.Write("Enter bit position: ");
        int b = int.Parse(Console.ReadLine());
        int maskBase = 1;
        int mask = maskBase << b;
        int iAndMask = i & mask;
        if (iAndMask != 0)
        Console.WriteLine("the value of the bit is 1");
        else
        Console.WriteLine("the value of the bit is 0");
    }
}

